package com.xmu.prcs.util;

/**
 * 分页类
 * @author frequent
 * @version 1.0,2012-3-19
 */
public class PageBean {
	private int countPage = 1;// 页数
	private int currentPage = 1;// 当前页
	private int first;// 首页
	private int last;// 末页
	private int next;// 下一页
	private int pageSize = 9;// 每页结果数
	private int pre;// 上一页

	public PageBean() {

	}
	
	public PageBean(int size){
		this.countPage = size % this.pageSize == 0 ? (size / this.pageSize )
				:(size / this.pageSize + 1);
	}

	public int getCountPage() {
		return countPage;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public int getFirst() {
		return first;
	}

	public int getLast() {
		return last;
	}

	public int getNext() {
		return next;
	}

	public int getPageSize() {
		return pageSize;
	}

	public int getPre() {
		return pre;
	}

	public void setCountPage(int countPage) {
		this.countPage = countPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public void setFirst(int first) {
		this.first = first;
	}

	public void setLast(int last) {
		this.last = last;
	}

	public void setNext(int next) {
		this.next = next;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public void setPre(int pre) {
		this.pre = pre;
	}
	
	public void setCurrentPage(String currentPage){
		try{
			this.currentPage = Integer.parseInt(currentPage);
		}catch(NumberFormatException e){
			//e.printStackTrace();
			this.currentPage = 1;
		}
	}
	
	public void setPageSize(String pageSize){
		try{
			this.pageSize = Integer.parseInt(pageSize);
		}catch(NumberFormatException e){
			//e.printStackTrace();
			this.pageSize = 10;
		}
	}
	
	public int getBeginIndex(){
		return (this.currentPage - 1) * this.pageSize;
	}
}
